// 组件调用的Component函数
import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import { store } from '../store/index'
// custom-tab-bar/index.js
Component({
  // 通过 storeBindingsBehavior 来实现自动绑定
	behaviors:[storeBindingsBehavior],
	storeBindings:{
		store,
		fields:['activeIndex'],
		actions:['setActiveIndex']
	},
  /**
   * 组件的属性列表
   */
  properties: {
  },

  /**
   * 组件的初始数据
   */
  data: {
    list:[{
      icon: 'home-o',
      text: "首页",
      url: "/pages/index/index"
    },
    {
      icon: 'label-o',
      text: "专题",
      url: "/pages/topic/topic"
    },
    {
      icon: 'apps-o',
      text: '分类',
      url: '/pages/cate/cate'
    },
    {
      icon: 'cart-o',
				text: '购物车',
				url: '/pages/cart/cart'
    },
    {
      icon: 'manager-o',
      text: '我的',
      url: '/pages/user/user'
    },
  ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event) {
			// 修改了active
			this.setActiveIndex(event.detail)
			// 找到点击那一行的地址
			wx.switchTab({
				url: this.data.list[event.detail].url
			});
		}
  }
})
